#!/bin/bash

# Copyright (C) Metaswitch Networks 2017
# If license terms are provided to you in a COPYING file in the root directory
# of the source code repository by which you are accessing this code, then
# the license outlined in that COPYING file applies to your use.
# Otherwise no rights are granted except for those provided to you by
# Metaswitch Networks in a separate written agreement.

set -ue

# Set up defaults for the site/etcd_key/etcd_cluster_key
local_site_name=site1
etcd_key=clearwater
etcd_cluster_key=unknown

# Pull in config
if [ -d /usr/share/clearwater/node_type.d ]
then
  . /usr/share/clearwater/node_type.d/$(ls /usr/share/clearwater/node_type.d | head -n 1)
fi
. /etc/clearwater/config

if [ $# -ne 2 ]
then
  echo "Usage: modify_nodes_in_queue <operation> <queue_key>"
  exit 1
fi

operation=$1
queue_key=$2

/usr/share/clearwater/clearwater-queue-manager/env/bin/python /usr/share/clearwater/clearwater-queue-manager/scripts/modify_nodes_in_queue.py "$operation" "${management_local_ip:-$local_ip}" "$local_site_name" "$etcd_cluster_key" "$etcd_key" "$queue_key"
